import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:x_common_utils/utils/inkWell_util.dart';
import 'package:get/get.dart';
import 'package:xinxuan/utils/color_util.dart';
import 'package:common_utils/common_utils.dart';

/// 消息提示框
class MessageDialog extends Dialog {

  final String message;
  final String title;
  final Color? messageColor;
  final TextAlign textAlign;
  final double? fontSize;
  MessageDialog({ required this.message, this.title = '', this.messageColor, this.textAlign = TextAlign.center, this.fontSize });

  @override
  Widget build(BuildContext context) {
    return Material(
      type: MaterialType.transparency,
      child: Center(
        child: Container(
          width: 320.w,
          decoration: BoxDecoration(
            color: bgWhiteColor,
            borderRadius: BorderRadius.circular(12.w)
          ),
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              Container(
                padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 32.h),
                child: Column(
                  children: [
                    TextUtil.isEmpty(title) ? Container() : Column(
                      children: [
                         Text(
                          title,
                          style: TextStyle(
                            color: textBlackColor,
                            fontSize: 20.sp
                          ),
                        ),
                        SizedBox(height: 20.h)
                      ],
                    ),
                    Text(
                      message,
                      textAlign: textAlign,
                      style: TextStyle(
                        fontSize: fontSize ?? 16.sp,
                        color: messageColor ?? textBlackColor
                      ),
                    )
                  ],
                ),
              ),
              Container(
                height: 55.h,
                decoration: BoxDecoration(
                  border: Border(
                    top: BorderSide(
                      width: .5,
                      color: lineColor
                    )
                  )
                ),
                child: InkWellUtil.shakeProofInkWell(Container(
                    height: 55.h,
                    alignment: Alignment.center,
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.only(
                        bottomRight: Radius.circular(12.w),
                      )
                    ),
                    child: Text(
                      '确定',
                      style: TextStyle(
                        fontSize: 16.sp,
                        color: mainTextColor
                      ),
                    ),
                  ), () async {
                    Get.back();
                  },
                  hoverColor: Colors.transparent,
                  splashColor: Colors.transparent,
                  highlightColor: Colors.transparent
                ),
              )
            ],
          ),
        ),
      ),
    );
  }
}